package com.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.mapper.SupplierMapper;
import com.example.pojo.Supplier;
import com.example.pojo.SupplierContact;
import com.example.service.SupplierContactService;
import com.example.mapper.SupplierContactMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Lenovo
* @description 针对表【supplier_contact】的数据库操作Service实现
* @createDate 2024-04-06 16:12:27
*/
@Service
public class SupplierContactServiceImpl extends ServiceImpl<SupplierContactMapper, SupplierContact>
    implements SupplierContactService{

    @Autowired
    private SupplierContactMapper supplierContactMapper;
    @Autowired
    private SupplierMapper supplierMapper;
    @Override
    public List<SupplierContact> allContact(String cname, Integer pid) {
        QueryWrapper<SupplierContact> q = new QueryWrapper<>();
        if(cname != null){
            q.like("cname", cname);
        }
        if(pid != null){
            q.eq("pid", pid);
        }
        return supplierContactMapper.selectList(q);
    }

    @Override
    public List<Supplier> all() {
        return supplierMapper.selectList(null);
    }

    @Override
    public int add(SupplierContact supplierContact) {
        return supplierContactMapper.insert(supplierContact);
    }

    @Override
    public Integer delete(Integer id) {
        return supplierContactMapper.deleteById(id);
    }

    @Override
    public Integer toUpdate(SupplierContact supplierContact) {
        return supplierContactMapper.updateById(supplierContact);
    }
}




